<?php
require_once './database/connection.php';
require_once './database/articles.php';
require_once './database/modify.php';
require_once './database/categories.php';
$obj = new articles();
$data = $obj->view_all();
$mod = new modify_data();
$ds = new categories();
$cate = $ds->laydanhsach();
?>
<div id="content">
        <div class="post">
            <form method="post" action="content_4.php">
                <p>title: </p> <input type="text" name="title"><br>
                <p>overview: </p> <input type="text" name="overview"><br>
                <p>body: </p> <input type="text" name="body"><br>
                <p>id_category: </p> <select name="id_category">
                                    <?php foreach ($cate as $data2){ 
                                        echo '<option value="'.$data2['id'].'">'.$data2['name'].'</option>';
                                    }
?>
                        </select><br>
                <input type="submit" name="them" value="them">
                <table>
                    <tr>
                        <td>id</td>
                        <td>title</td>
                        <td>overview</td>
                        <td>id_category</td>
                    </tr>
                    <?php
                    foreach ($data as $dulieu){
                        echo "<tr><td>".$dulieu['id']."</td><td>".$dulieu['title']."</td><td>".$dulieu['overview']."</td><td>".$dulieu['id_category']."</td>";
                    }
                    ?>
                </table>
            </form>
<?php 
    if(isset($_POST['them'])){
        $mod->them_data();
        echo 'them thanh cong';
        header("Location: index.php");
    }
?>
        </div>
    <!-- DC Pagination:A1 Start -->
    <!-- DC Pagination:A1 End -->
</div>

